package cn.progen.sqlbuilder;

import java.util.ArrayList;
import java.util.List;

public class WhereBuilder implements IWhere {	
	private StringBuilder sb=new StringBuilder();
	private List<Object> arges=new ArrayList<>();

	@Override
	public IWhere GreaterThanOrEq(String columan, Object arge) {
		sb.append(columan).append(">=?");
		arges.add(arge);
		return this;
	}

	@Override
	public IWhere GreaterThan(String columan, Object arge) {
		sb.append(columan).append(">?");
		arges.add(arge);
		return this;
	}

	@Override
	public IWhere LessThanOrEq(String columan, Object arge) {
		sb.append(columan).append("<=?");
		arges.add(arge);
		return this;
	}

	@Override
	public IWhere LessThan(String columan, Object arge) {
		sb.append(columan).append("<?");
		arges.add(arge);
		return this;
	}

	@Override
	public IWhere EqualTo(String columan, Object arge) {
		sb.append(columan).append("=?");
		arges.add(arge);
		return this;
	}

	@Override
	public IWhere and() {	
		sb.append(" and  ");
		return this;
	}

	@Override
	public IWhere or() {
		sb.append(" or  ");
		return this;
	}

	@Override
	public IWhere scopeLeft() {
		sb.append(" (  ");
		return this;
	}

	@Override
	public IWhere scopeRight() {
		sb.append(" ) ");
		return this;
	}

	@Override
	public String getSql() {		
		return sb.toString();
	}

	@Override
	public List<Object> getArges() {		
		return this.arges;
	}

	@Override
	public IWhere BetweenAnd(String columan, Object arge1, Object arge2) {
		sb.append(columan).append(" between ? and ?");
		arges.add(arge1);
		arges.add(arge2);
		return this;
	}

	@Override
	public IWhere where(String sql) {
		sb.append(sql);
		return this;
	}
	
}
